package de.gwtprime.client.views;

import com.google.gwt.core.shared.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;

import de.gwtprime.client.ClientFactory;
import de.gwtprime.client.widgets.QuestionWidget;
import de.gwtprime.shared.requestFactory.QuestionProxy;

public class QuestionViewImpl extends Composite implements QuestionView {

	interface QuestionViewImplUiBinder extends UiBinder<Widget, QuestionViewImpl>{};
	QuestionViewImplUiBinder uiBinder = GWT.create(QuestionViewImplUiBinder.class);
	
	private Presenter presenter;
	
	private String name;
	
		
	@UiField SimplePanel qustionWidget;
	
	ClientFactory clientFactory;
	
	public QuestionViewImpl(final ClientFactory clientFactory) {
		initWidget(uiBinder.createAndBindUi(this));
		this.clientFactory = clientFactory;
	}

	@Override
	public void setName(String name) {
		this.name = name;
		
	}

	@Override
	public void setPresenter(Presenter presenter) {
		this.presenter = presenter;
		
	}

	@Override
	public void setQuestion(final QuestionProxy question) {
		
		qustionWidget.clear();
		qustionWidget.add(new QuestionWidget(question, clientFactory));
		
	}
	
	
}
